home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2002 September
/
PCWorld_2002-09_cd.bin
/
Software
/
Vyzkuste
/
httrack
/
httrack-3.20RC4.exe
/
{app}
/
src
/
strip_cr.in
< prev
Wrap
Text File
|
2001-01-11
|
773b
|
33 lines
#!__PERL__
# A simple script to convert DOS text files to
# Unix one. Useful to strip all CR on .c and .h
# sourcefiles.
# Usage: strip_cr <files>
foreach $fname (@ARGV) {
$ad=1;
if (open(FL,$fname)) {
if (open(FO,">".$fname.".tmp")) {
while(<FL>) {
s/\r\n$/\n/g;
print FO "$_";
}
close(FL);
close(FO);
if ((-s $fname) != (-s $fname.".tmp")) {
print("Stripping ".$fname."..\n");
rename($fname.".tmp",$fname);
} else {
unlink($fname.".tmp");
}
} else {
print "Unable to open ".$fname.".tmp\n";
}
} else {
print "Unable to open $fname\n";
}
}
if (!$ad) {
print "Ensure that a text file has no lines ended with CR (DOS)\n";
print "Usage: strip_cr <file>\n";
}